package com.ktgj.flight.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ktgj.common.log.annotation.Log;
import com.ktgj.common.log.enums.BusinessType;
import com.ktgj.common.security.annotation.PreAuthorize;
import com.ktgj.flight.domain.FlightInvoiceOperation;
import com.ktgj.flight.service.IFlightInvoiceOperationService;
import com.ktgj.common.core.web.controller.BaseController;
import com.ktgj.common.core.web.domain.AjaxResult;
import com.ktgj.common.core.utils.poi.ExcelUtil;
import com.ktgj.common.core.web.page.TableDataInfo;

/**
 * 补打发票操作信息Controller
 * 
 * @author ruoyi
 * @date 2021-10-26
 */
@ControllerAdvice
@RestController
@RequestMapping("/operation")
public class FlightInvoiceOperationController extends BaseController
{
    @Autowired
    private IFlightInvoiceOperationService flightInvoiceOperationService;

    /**
     * 查询补打发票操作信息列表
     */
    @PreAuthorize(hasPermi = "flight:operation:list")
    @GetMapping("/list")
    public TableDataInfo list(FlightInvoiceOperation flightInvoiceOperation)
    {
        startPage();
        List<FlightInvoiceOperation> list = flightInvoiceOperationService.selectFlightInvoiceOperationList(flightInvoiceOperation);
        return getDataTable(list);
    }

    /**
     * 导出补打发票操作信息列表
     */
    @PreAuthorize(hasPermi = "flight:operation:export")
    @Log(title = "补打发票操作信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FlightInvoiceOperation flightInvoiceOperation) throws IOException
    {
        List<FlightInvoiceOperation> list = flightInvoiceOperationService.selectFlightInvoiceOperationList(flightInvoiceOperation);
        ExcelUtil<FlightInvoiceOperation> util = new ExcelUtil<FlightInvoiceOperation>(FlightInvoiceOperation.class);
        util.exportExcel(response, list, "补打发票操作信息数据");
    }

    /**
     * 获取补打发票操作信息详细信息
     */
    @PreAuthorize(hasPermi = "flight:operation:query")
    @GetMapping(value = "/{invoiceId}")
    public AjaxResult getInfo(@PathVariable("invoiceId") Long invoiceId)
    {
        return AjaxResult.success(flightInvoiceOperationService.selectFlightInvoiceOperationById(invoiceId));
    }

    /**
     * 新增补打发票操作信息
     */
    @PreAuthorize(hasPermi = "flight:operation:add")
    @Log(title = "补打发票操作信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FlightInvoiceOperation flightInvoiceOperation)
    {
        return toAjax(flightInvoiceOperationService.insertFlightInvoiceOperation(flightInvoiceOperation));
    }

    /**
     * 修改补打发票操作信息
     */
    @PreAuthorize(hasPermi = "flight:operation:edit")
    @Log(title = "补打发票操作信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FlightInvoiceOperation flightInvoiceOperation)
    {
        return toAjax(flightInvoiceOperationService.updateFlightInvoiceOperation(flightInvoiceOperation));
    }

    /**
     * 删除补打发票操作信息
     */
    @PreAuthorize(hasPermi = "flight:operation:remove")
    @Log(title = "补打发票操作信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{invoiceIds}")
    public AjaxResult remove(@PathVariable Long[] invoiceIds)
    {
        return toAjax(flightInvoiceOperationService.deleteFlightInvoiceOperationByIds(invoiceIds));
    }
}
